<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>质量自评</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="./css/BtnStyle.css" rel="stylesheet">
<link href="./css/LiChildrenStyle.css" rel="stylesheet">
<link href="./css/UlStyle.css" rel="stylesheet">
<style type="text/css">
.li_body {
	margin-top: 0.5em;
	min-height: 6em;
	line-height: 6em;
	background-color: white;
	padding-left:1.5em;
}

.li_body_ .a {
	padding-left: 0.7em;
	min-height: 4.5em;
}

.childrenLeft {
	width: 23%;
	
	
	
}

.childrenRight {
	width: 77%;
	margin-left: 23%
}

.f5 {
	text-align: center;
	width: 5em;
}

.f4 {
	letter-spacing: 0.33em;
	margin-right: -0.33em;
}

.f3 {
	letter-spacing: 1em;
	margin-right: -1em;
}

.f2 {
	letter-spacing: 3em;
	margin-right: -3em;
}

ul li input {
	border: none;
	outline: medium;
	padding-left: 15px;
	vertical-align: middle;
	font-size: 2.8em;
}

.childrenRight textarea {
	clear: both;
	border: none;
	outline: medium;
	padding-left: 15px;
	vertical-align: middle;
	font-size: 3.5em;
}

ul li label a {
	font-size: 2.8em;
	display: inline-block;
	vertical-align: middle;
}

ul li label .radio {
	clear: both;
	width: 0.8em;
	height: 0.8em;
	vertical-align: middle;
}

.btn {
	float: left;
	margin-top: 1em;
}
.padding_a{
    


}
</style>
<script type="text/javascript" src="./plugins/jquery-1.8.2.min.js">
	
</script>
<script type="text/javascript">
    var Id = null;
    var index = -1;
    var standardValue,minValue,maxValue;
    var saveFlag =-1;
    var uId , userCompanyName;
    var HgStute ;
    var ZpRe = "";
	window.onload = function loading() {
		getParams();
		getCookie();
	}
	function getParams() {
		var ss = decodeURI(location.search.replace('?', ''));
        var info = ss.split('&');
         Id = info[7];
	
		$('#paramName').html(info[0]);
		$('#Qd').html(info[2]);
		standardValue = info[3]
		$('#standard').html(standardValue);
		
		if(info[1] == '定性参数'){

		   $('#li_minValue').hide();
		   $('#li_maxValue').hide(); 
		   $('#qDescribe').html(info[4]);
		   saveFlag = 0;
		}else{

		   $('#li_qDescribe').hide();
		   minValue = info[5];		  
		   $('#minValue').html(minValue);		   
		   maxValue = info[6];
		   $('#maxValue').html(maxValue); 
		   saveFlag = 1;
		
		}
		
		
		
	}

	$("#text").height($("#text")[0].scrollHeight);
	$("#text").on("keyup keydown", function() {
	$(this).height(this.scrollHeight);
	});
	
	
	function SaveQuality(){

     if($('#NotType').val() == '' && HgStute == '不合格' ){
         alert("请填写不合格类型后进行提交！");
     }else{
          //自评结果不合格
       
         if($("input[type='radio'][name='ES']:checked").val() == '否' && $("input[type='radio'][name='ZpRe']:checked").val() == undefined){
            //不进入二级审批，需填写自审结果           
             alert("请填写自审结果后进行提交！");
         }else{
            
             saveQualityByAjax("SaveQuality");
         }
        
     }
	 
	}
	
	//公用ajax
	function saveQualityByAjax(searchText){
	$.ajax({
			type : "post",
			url : "servlet/SaveInfoServlet",
			data : {
				paramName : searchText,
				paramText : $('#ScValue').val(),  //实测值
				paramText2 :$("input[type='radio'][name='Dession']:checked").val(),   //合格判定
				paramText3 : $('#content').val(),    //备注
				paramText4 : uId, //用户Id
			//	paramText5 : userCompanyName,	//用户Name	
				paramText5 : $('#NotType').val(),	//不合类型
				paramText6 : $("input[type='radio'][name='ZpRe']:checked").val(),  //自审结果
				paramText7 : Id
				
			},
			dataType : "text",
			success : function(data, textStatus) {
			  //  alert("生产计划" + JSON.stringify(data));
		       if(data=true){
		          window.history.go(-1);
		       }else{
		          alert("保存失败，请重试！！");
		       }
			   
			     
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				alert("请刷新界面后，重试！"); //+ textStatus + errorThrown
			}
		});

	
	}
	
	function lostFocus(){
	 //  alert("失去焦点");
	   var scValue = $('#ScValue').val();
	 if(saveFlag == 0){
	      // 定性参数保存
	      if(scValue == standardValue){
	          //合格
	          $("input[name='Dession']").get(0).checked=true;
	           $('#li_NotType').hide(); 
	           HgStute = "合格";
	           $('#li_ES').hide();
	      }else{
	          //不合格
	          $("input[name='Dession']").get(1).checked=true; 
	          $('#li_NotType').show();
	          HgStute = "不合格";
	          $('#li_ES').show(); 
	           $("input[name='ES']").get(1).checked=true;
	      }
	 
	 }else{
	      // 定量参数保存
	       if(scValue >= minValue && scValue <= maxValue){
	          //合格	        
	          $("input[name='Dession']").get(0).checked=true; 
	          $('#li_NotType').hide();
	          HgStute = "合格";
	          $('#li_ES').hide(); 
	         
	      }else{
	          //不合格
	          $("input[name='Dession']").get(1).checked=true;
	          $('#li_NotType').show(); 
	          HgStute = "不合格";	 
	          $('#li_ES').show(); 
	          $("input[name='ES']").get(1).checked=true; 
	                  
	      }
	 
	 }
	     ESChange();
	}
	
	//使用cookie获取用户名和id
	function getCookie() {
	
		var arr = (decodeURI(document.cookie)).split(';');
	
		for ( var i = 0; i < arr.length; i++) {
			var arr2 = arr[i].split('=');
			
			var item = arr2[0].replace('"','').replace('"','').replace(' ','');
			if(item == 'uId'){
			     
			      uId = arr2[1];
			}
			
			
		//	if(item == 'userName'){
			     
			  //    userCompanyName = arr2[1].replace('"','').replace('"','');
			//      userCompanyName='王五';
		//	}
		}
	}
	
	function ESChange(){
	    //   alert("value--"+);
	     $("input[type='radio'][name='ZpRe']:checked").removeAttr('checked');
	     
	     if($("input[type='radio'][name='ES']:checked").val() == '否'){
	        
	         $('#li_ZpRe').show(); 
	         
	     
	     }else{
	        $('#li_ZpRe').hide();
	     }
	}
</script>
</head>


<body
	style="background-color: #F0F0F0;padding-left: 0em;padding-right: 0em;">
	<div style="width:100%;">
		<ul>
			<li class="li_head"><a id="paramName">参数名称</a>
			</li>
			<li class="parentLi" style="padding-left:1.5em">
				<div class="childrenLeft">
					<a class="f5" >检验标准：</a>
				</div>
				<div class="childrenRight">
					<a id="Qd"></a>
				</div>
			</li>
			<br>
			<li class="li_body"><a class="f4">标准值：</a><a id="standard"></a>
			</li>
			<li class="li_body" id="li_minValue"><a class="f4">最小值：</a><a id="minValue"></a>
			</li>
			<li class="li_body" id="li_maxValue"><a class="f4">最大值：</a><a id="maxValue"></a>
			</li>
			<li class="li_body" id="li_qDescribe"><a class="f5">定性描述：</a><a id="qDescribe"></a> 
			</li>
			<li class="li_body"><a class="f4">实测值：</a><input style="width: 77%" placeholder="请输入实测结果值" id="ScValue"  onBlur="lostFocus()">
			</li>
			<li class="li_body"><a class="f5">自评判定：</a> <label ><input
					class="radio" name="Dession" type="radio" value="合格" disabled="disabled"/><a>合格</a> </label> <label
				style="margin-left: 3em;"><input class="radio"
					name="Dession" type="radio" value="不合格"  disabled="disabled"/><a>不合格</a> </label></li>
			<li class="li_body" id="li_NotType" style="display: none"><a class="f5">不合类型：</a><input style="width: 77%" placeholder="请输入不合格类型" id="NotType"  >
			</li>
			<li class="li_body" id="li_ES" style="display: none;"><a class="f5">二级审批：</a> <label ><input
					class="radio" name="ES" type="radio" value="是"  onchange="ESChange()" /><a> 是 </a> </label> <label
				style="margin-left: 4em;"><input class="radio"
					name="ES" type="radio" value="否"  onchange="ESChange()"/><a> 否 </a> </label></li>
			<li class="li_body" id="li_ZpRe"  style="display: none;"><a class="f5">自审结果：</a> 
			<label ><input class="radio" name="ZpRe" type="radio" value="返修" /><a> 返修</a> </label>
		    <label style="margin-left: 1.5em;"><input class="radio" name="ZpRe" type="radio" value="特采"  /><a> 特采 </a> </label>
			<label style="margin-left: 1.5em;"><input class="radio" name="ZpRe" type="radio" value="验证"  /><a> 验证 </a> </label>
			<label style="margin-left: 1.5em;"><input class="radio" name="ZpRe" type="radio" value="报废"  /><a> 报废 </a> </label>
					</li>
			
			
			
			<li class="parentLi" style="height: auto;padding-left:1.5em" >
				<div class="childrenLeft">
					<a class="f3" >备注：</a>
				</div>
				<div class="childrenRight" >
					<script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
					<textarea id="content" rows="" cols=""
						style="width: 100%;min-height:3.5em;height:auto;vertical-align: top"  
						placeholder=""></textarea>
					<span class="contentcount"
						style="margin-left: 80%;font-size: 2.3em">0</span><span
						style="font-size: 2.3em">/140</span>
					<script type="text/javascript" src="./Js/SubmitCommon.js"></script>
				</div></li>

		</ul>

		<div
			style="position: relative;padding-left: 38%;">
			
			<button class="btn change3 "  onclick="SaveQuality()">
				<span>提交</span>
			</button>
		</div>
	</div>
</body>
</html>
<!-- 
<button class="btn change3 " style="margin-right: 18%">
				<span>拍照</span>
			</button>


 -->
